package veda;


import cn.hutool.core.collection.CollectionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.stream.Stream;

public class CollectionSubtract {
    private static Logger logger = LoggerFactory.getLogger(CollectionSubtract.class);

    public static void main(String[] args) {
        Set<String> list1 = CollectionUtil.newHashSet("1","3", "2","5");
        Set<String> list2 = CollectionUtil.newHashSet("1","2","8");

        Stream<String> stream = list1.stream();

        boolean containsElements = stream.allMatch(list2::contains);
        System.out.println("差集="+CollectionUtil.subtract(list2,list1));
        System.out.println("差集="+CollectionUtil.subtract(list1,list2));
        System.out.println("Does list1 contain all elements from list2? " + containsElements);
    }
}
